package com.hxwang.tanke;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Objects;

/**
 * <H2> 加载图片 </H2>
 *
 * @author hxwang
 * @data 2022/12/20
 */

public class ResoourcesMgr {
    public static BufferedImage tankL, tankR, tankU, tankD;
    public static BufferedImage mTankL, mTankR, mTankU, mTankD;
    public static BufferedImage bulletL, bulletR, bulletU, bulletD;
    public static BufferedImage[] explodes = new BufferedImage[16];

    static {
        try {
            tankU = ImageIO.read(Objects.requireNonNull(ResoourcesMgr.class.getClassLoader().getResourceAsStream("images/BadTank2.png")));
            tankL = ImageUtil.rotateImage(tankU, -90);
            tankR = ImageUtil.rotateImage(tankU, 90);
            tankD = ImageUtil.rotateImage(tankU, 180);

            mTankU = ImageIO.read(Objects.requireNonNull(ResoourcesMgr.class.getClassLoader().getResourceAsStream("images/GoodTank1.png")));
            mTankL = ImageUtil.rotateImage(mTankU, -90);
            mTankR = ImageUtil.rotateImage(mTankU, 90);
            mTankD = ImageUtil.rotateImage(mTankU, 180);

            bulletU = ImageIO.read(Objects.requireNonNull(ResoourcesMgr.class.getClassLoader().getResourceAsStream("images/bulletU.png")));
            bulletL = ImageUtil.rotateImage(bulletU, -90);
            bulletR = ImageUtil.rotateImage(bulletU, 90);
            bulletD = ImageUtil.rotateImage(bulletU, 180);

            for (int i = 0; i < 16; i++) {
                explodes[i] = ImageIO.read(Objects.requireNonNull(ResoourcesMgr.class.getClassLoader().getResourceAsStream("images/e" + (i + 1) + ".gif")));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
